<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>数据统计</el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
      <div id="main" style="width: 900px;height: 400px;"></div>
    </el-card>
  </div>
</template>

<script>
import { log } from "util";
// import echarts from "echarts";
var echarts = require("echarts");
export default {
  data() {
    return {
      charts: {
        
      }
    };
  },

  methods: {
    async initEcharts() {
      var myChart = echarts.init(document.getElementById("main"));
      var res = await this.axios.get("reports/type/1");

      if (res.meta.status === 200) {
        this.charts = res.data;
      }
      console.log(this.charts);
      // console.log(this.charts);
      
      var options = {
        title: {
          text: "用户来源"
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985"
            }
          }
        },
        legend: {
          data: this.charts.legend.data
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: this.charts.xAxis[0].data
          }
        ],
        yAxis: [
          {
            type: "value"
          }
        ],
        series: this.charts.series
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(options);
    }
  },

  created() {},
  mounted() {
    this.initEcharts();
  }
};
</script>

<style lang='less' scoped>
</style>
